<?php
/**
 * Created by PhpStorm.
 * User: nhson219
 * Date: 10/8/2014
 * Time: 12:38 AM
 */
?>
<?php $this->load->view('header'); ?>

    <!-- Page Content -->
    <div id="search-project">
        <?php echo $this->load->view('sideBlocks/searchBlock') ?>
    </div>
    <div class="wrap-content wrap-project">
        <div class="container">
            <div class="row find-freelance">
                <div class="col-lg-12 col-sm-12 col-md-12 col-xs-12 top-content-find-freelancer no-padding">
                    <div class="col-lg-4 col-sm-4 col-md-4 col-xs-4 no-padding">
                        <div class="f30-m">TOP APPLANCERS</div>
                        <div class="f18-m green-2">SHOWING <?php echo $countFreelancer?> FREELANCERS</div>
                    </div>
                    <div class="col-lg-8 col-sm-8 col-md-8 col-xs-8 f18-m">
                        <button class="btn btn-primary bg-green">POST A JOB,IT's FREE</button>
                    </div>
                </div>

                <div class="col-lg-3 col-sm-3 col-md-3 col-xs-3 menu-categories-find">
                    <p><a class="f18-m green-2 " href="#">All Categories</a> </p>
                    <ul>
                        <?php
                            if(count($listParentCategories) > 0){
                                foreach($listParentCategories as $item) {
                        ?>

                                    <li><a href="/pc/<?php echo site_url('users/findFreelancer').$item['id']?>"><?php echo $item['name']?></a>
                                        <ul>
                                            <?php
                                                if( (isset($item['child']) == TRUE ) &&    count($item['child']) > 0) {
                                                    foreach ($item['child'] as $item_child) {
                                                        ?>
                                                        <li><a href="/c/<?php echo $item_child['id']?>"><p><?php echo $item_child['name']?>&nbsp;<?php echo $item_child['num']?></p></a></li>
                                                    <?php
                                                    }
                                                }
                                            ?>
                                        </ul>
                                    </li>
                        <?php   }
                            }
                        ?>

                    </ul>
                    <p><a class="f18-m green-2 " href="#">Country</a> </p>
                    <select class="select-sort selectpicker" name="sort">
                        <?php
                            if($countries->num_rows() > 0) {
                                foreach ($countries->result() as $item) {
                        ?>
                                    <option><?php echo $item->country_name?></option>
                        <?php
                                }
                            }
                        ?>
                    </select>
                    <p><a class="f18-m green-2 " href="#">All Feedback</a> </p>
                    <input  value="2" type="number" data-star-captions="{}" data-default-caption="{rating}" class="rating" min=0 max=5  data-size="xs" disabled="disabled">
                    <input  value="2" type="number" data-star-captions="{}" data-default-caption="{rating}" class="rating" min=0 max=5  data-size="xs" disabled="disabled">
                    <input  value="2" type="number" data-star-captions="{}" data-default-caption="{rating}" class="rating" min=0 max=5  data-size="xs" disabled="disabled">
                    <p><a class="f18-m green-2 " href="#">Any number of review</a> </p>
                    <ul>
                        <li><a href="#">At least 5</a> </li>
                        <li><a href="#">At least 10</a> </li>
                        <li><a href="#">At least 15</a> </li>
                    </ul>

                </div>
                <?php
                    if($listFreelancer->num_rows() > 0){
                        foreach($listFreelancer->result() as $item){
                            if(isset($this->loggedInUser->id) == TRUE){
                                if(getStatusWatchList($this->loggedInUser->id,$item->uid) == TRUE){
                                    $icon_heart = "glyphicon-heart";
                                }else{
                                    $icon_heart = "glyphicon-heart-empty";
                                }
                            }else{
                                $icon_heart = "glyphicon-heart-empty";
                            }
                ?>

                <div class="info-find-freelancer col-lg-9 col-sm-9 col-md-9 col-xs-9 no-padding">
                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 no-padding">
                        <img src="<?php
                        if ( (is_file_exists($item->logo) == TRUE ) && ($item->logo != "")) echo uimage_url($item->logo); else echo image_default();
                        ?>" class="img-responsive" />
                    </div>
                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9 no-padding">
                        <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding" data-id="<?php echo $item->uid?>"><?php echo $item->user_name?> <span id="btn-watchlist" class="glyphicon <?php echo $icon_heart?>"></span></div>
                        <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">
                           <?php echo $item->profile_desc;?>
                        </div>
<!--                        <span class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">-->
<!--                            <a href="#">more</a>-->
<!--                        </span>-->
                        <div class="clear"></div>
                        <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding">
                            <span class="col-md-3 col-lg-1 col-xs-3 col-sm-3 no-padding">Skills: </span>
                            <div class="list-skills-project col-md-9 col-lg-11 col-xs-9 col-sm-9 no-padding">
                                <ul>
                                    <li class="bg-yellow"><a href="#">Obj-C</a> </li>
                                    <li class="bg-pink-2"><a href="#">Obj-C</a> </li>
                                    <li class="bg-lam"><a href="#">Obj-C</a> </li>
                                </ul>
                            </div>
                        </div>
                        <div class="col-md-12 col-lg-12 col-xs-12 col-sm-12 no-padding list-dev-info">
                            <div class="col-md-2 col-lg-2 col-xs-2 col-sm-2 no-padding">
                                <span class="glyphicon glyphicon-map-marker"></span>
                                Vietnam |
                            </div>
                            <div class="col-md-4 col-lg-4 col-xs-4 col-md-4 no-padding">
                                <input  value="<?php echo $item->user_rating?>" type="number" data-star-captions="{}" data-default-caption="{rating}" class="rating" min=0 max=5  data-size="xs" disabled="disabled">
                            </div>
                            <div class="col-lg-2 col-md-3 col-xs-3 col-sm-3 no-padding">
                               | 50 jobs |
                            </div>
                            <div class="col-lg-3 col-md-3 col-xs-3 col-sm-3 no-padding">
                                $208,252 Earned
                            </div>
                        </div>
                    </div>
                </div> <!-- info-find-freelancer -->
                <?php }  } ?>

                <div class="col-lg-offset-9 col-lg-3"><?php echo $this->pagination->create_links2();?></div>






            </div> <!-- end row content -->
        </div>
    </div> <!-- wrap-content -->
<script>
    $('body').on('click','#btn-watchlist',function(){
        var user_id = $(this).parent().attr('data-id');
       if($(this).hasClass(('glyphicon-heart'))){
           $(this).removeClass('glyphicon-heart');
           $(this).addClass('glyphicon-heart-empty');
           $.ajax({
               type: "POST",
               data : "user_id="+user_id,
               url : BASE_URL+"index.php/users/removeWatchList",
               success:function(data){
                   var data = $.parseJSON(data);
                   if(data.status == 'success'){
                       alert('Xóa thành công');
                   }else{
                       alert('Xóa thất bại');
                   }
               }
           });
       }else{
           $(this).removeClass('glyphicon-heart-empty');
           $(this).addClass('glyphicon-heart');
           $.ajax({
               type: "POST",
               data : "user_id="+user_id,
               url : BASE_URL+"index.php/users/addWatchList",
               success:function(data){
                   var data = $.parseJSON(data);
                   if(data.status == 'success'){
                       alert('Thêm thành công');
                   }else{
                       alert('Thêm thất bại');
                   }
               }
           });
       }
    });
</script>
<?php $this->load->view('footer'); ?>